#include "JctoSplitString.h"
#include <malloc.h>

char (*jctoSplitString(const char*str,int*dataNamesCnt))[512]
{
    (*dataNamesCnt)=1;
    for(int i=0;str[i];(*dataNamesCnt)+=(str[i]==','&&str[i+1]!=0),++i){}
    char (*dataName)[512]=malloc(sizeof(char)*512*(*dataNamesCnt));
    for(int i=0,j=0,k=0;;++i)
    {
        if(str[i]==',')
        {
            dataName[j][k]=0;
            ++j;
            k=0;
            if(str[i+1]==0)
            {
                break;
            }
        }
        else
        {
            dataName[j][k]=str[i];
            ++k;
        }
        if(0==str[i])
        {
            break;
        }
    }
    return dataName;
}
